<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <link rel="stylesheet" href="/assets/home/css/mui.min.css"  />
    <link rel="stylesheet" href="/assets/home/css/animate.min.css" />
    <link rel="stylesheet" href="/assets/home/css/reset.css"  />
    <link rel="stylesheet" href="/assets/home/css/poster.css">
    <title>推广海报</title>
    <script src="/assets/home/js/jquery-1.9.1.min.js"></script>
    <script src="/assets/home/js/mui.min.js"></script>
    <script src="/assets/home/js/wow.min.js"></script>
</head>
<body>
    <div class="content">
        <div class="poster wow">
            <!-- <img id="poster" src="/assets/home/images/poster-back.png" alt="点击按钮重新生成海报"> -->
            <img id="poster" src="{$business.poster_text}" alt="点击按钮重新生成海报">
        </div>
    
        <div class="link wow" data-wow-delay="100ms">
            <input type="text" placeholder="普通输入框" readonly="" id="url" value="{$link}">   
            <button class="mui-btn mui-btn-primary" type="button" id="btn">点击复制</button>
        </div>
    
        <div class="update wow" data-wow-delay="200ms">
            <button class="mui-btn mui-btn-success" type="button" id="update">重新生成海报</button>
        </div>
    </div>
</body>
</html>
<script>
    if(!'{$business.poster_text}'){
        poster(false)
    }
    $('#btn').click(function(){
        $('#url')[0].select()
        document.execCommand('copy') && mui.toast('复制成功', {duration: 3000})
    })
    $('#update').click(function(){
        poster(true)
    })
    function poster(isUpdate)
    {
        $.post('/home/center/poster')
        .then((data)=>{
            if(data.code){
                mui.toast(`${isUpdate?'重新':''}生成海报成功`, {duration: 3000})
                $('#poster').prop('src',data.msg)
                $('#url').val(data.link)
            }else{
                mui.toast(data.msg, {duration: 3000})
            }
        })
    }
    new WOW({
        boxClass: 'wow',      // 需要执行动画的元素的 class(默认是wow)
        animateClass: 'animated fadeInDown', // animation.css 动画的 class(默认是animated)
        offset: 0,          // 距离可视区域多少开始执行动画(默认为0)
        mobile: true,       // 是否在移动设备上执行动画(默认为true)
        live: true,       // 异步加载的内容是否有效(默认为true)
        scrollContainer: '#box' // 可选滚动容器选择器，否则使用窗口
    }).init();
</script>